<?php
// src/Pyaf/GymBundle/Repository/GrupoMuscularesRepository.php
namespace Pyaf\GymBundle\Repository;

use Doctrine\ORM\EntityRepository;

/**
 * Description of GrupoMuscularesRepository
 *
 * @author Toshiba P755-S5272
 */
class GrupoMuscularesRepository extends EntityRepository{
    
    public function findAllOrderByNombre() {                
        return $this->getEntityManager()
                    ->createQuery('SELECT gm FROM PyafGymBundle:GrupoMusculares gm ORDER BY gm.nombre ASC')
                    ->getResult();
    }
    
    public function findGrupoMuscular($id) {                
        return $this->getEntityManager()
                    ->createQuery("SELECT gm FROM PyafGymBundle:GrupoMusculares gm WHERE gm.id = $id")
                    ->getOneOrNullResult();
    }
    
    public function save($grupoMuscular){
        $this->saveGrupoMuscular($grupoMuscular);
    }
    
    public function saveGrupoMuscular($grupoMuscular) {
        $em = $this->getEntityManager();
        $em->persist($grupoMuscular);
        $em->flush();
    }
}

?>
